package com.atguigu.srb.sms.config;

import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

//@Configuration //此注解标注的配置类 项目启动时一定会初始化对象添加到容器中
//除此之外 我们可以在需要此配置类的组件中加入注解EnableConfigurationProperties来手动开启初始化此配置类对象
@ConfigurationProperties(prefix = "aliyun.sms")
@Data
public class SmsProperties implements InitializingBean {
    //服务器地址
    private String host ;
    //资源路径
    private String path ;
    //请求方式
    private String method ;
    //在短信平台购买服务时的唯一id
    private String appcode ;

    public static String HOST ;
    public static String PATH ;
    public static String METHOD ;
    public static String APPCODE ;

    //对象初始化后调用
    @Override
    public void afterPropertiesSet() throws Exception {
        SmsProperties.HOST = this.host;
        SmsProperties.PATH = this.path;
        SmsProperties.METHOD = this.method;
        SmsProperties.APPCODE = this.appcode;
    }
}
